<html>
<!--  We can show simple graphics (bars) by using cell templates  -->
<style>
 {{{defaultstyle}}}
 body {margin: 20px 20px}
 table {box-shadow: 5 5 10 #777; width: 600; }
 h2 {color: #666; }
 td, th {border: solid #eee 1px; font-size: 12px; padding: 2 2; }
 th {background: #888; color: white; padding: 5px 5px; draggable: true; }
 .total {background: #888; color: white; font-weight: bold}
 .bar {display: inline-block;
  margin: 5 5 5 5;
  background-color: red; /* for browsers */
  background: linear-gradient(top, #aa4444, #ff8888 50%, #aa4444);
  -moz-background: linear-gradient(top, #aa4444, #ff8888 50%, #aa4444);
  height: 10px;
  box-shadow: 4 4 3 #ddaaaa;
 }
</style>

<h2>Top Sales</h2>

<DATAPACKET>
 <METADATA>
  <FIELDS>
   <FIELD name="FIRSTNAME" total="Total" caption="First Name"/>
   <FIELD name="LASTNAME" total="count(*)" caption="Last Name"/>
   <FIELD name="SALES" total="sum" format="# ### ###.##" caption="Sales"/>
   <FIELD name="BAR2" width="200" caption="%(max)" template="='<div style=''float: left; height: 20px; margin-top: 5px;
     background: linear-gradient(top, lightgreen, green); box-shadow: 2 2 2 #aaa; width:'+formatfloat('0', 100*sales/totals('sales', 'max'))+'%''> </div>'"/>
   <FIELD name="BAR" width="200" caption="%">
    <template-cell>
     <div class="bar" style="width: {{PERCENT}}%"/>
    </template-cell>
   </FIELD>
  </FIELDS>
  <SQL>
select e.firstname, e.lastname, sum(o.itemstotal) sales,
 cast(200*sum(o.itemstotal)/(select sum(itemstotal) from orders ) as integer) percent
from customer c join orders o on o.custno=c.custno
join employee e on e.empno=o.empno
group by 1, 2
order by 4 desc
  </SQL>
 </METADATA>
</DATAPACKET>


</html>
